package com.mobileares.midp.widgets.client.list;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Label;
import com.mobileares.midp.widgets.client.utils.ITextProvider;

/**
 * Created by IntelliJ IDEA.
 * User: Tom
 * Date: 2011-4-9
 * Time: 17:56:57
 * To change this template use File | Settings | File Templates.
 */
public class CheckBoxListItem<T> extends ListItem<T> {
    private CheckBox checkBox;


    public CheckBoxListItem(T ob) {
        super(ob);
    }

    protected void init() {
        super.init();
        checkBox = new CheckBox();
        checkBox.setStyleName("list-item-box");
        container.insert(checkBox, 0);
        Label foot = new Label();
        foot.setStyleName("list-item-foot");
        container.add(foot);
        checkBox.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                checkBox.setValue(!checkBox.getValue());
//                ((MultiListWidget) parent).setSelected(CheckBoxListItem.this, true,false);
            }
        });
        widget.addStyleName("list-item-check");
    }

    public boolean getCheckStatus() {
        return checkBox.getValue().booleanValue();
    }

    void setCheckStatus(boolean flag) {
        checkBox.setValue(flag);
    }
}
